﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Xml.Linq;
namespace ClientesServicios.Controllers
{
    public class HomeController : Controller
    {

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult ServicioWCF(string busqueda="", int cant = 10, int id = -1)
        {
            XElement datos = new XElement("No-Data");
            XElement detalle = null;
            ViewBag.id = 0;
            try
            {
                WCF.EventosWCFClient c = new WCF.EventosWCFClient();
                datos = c.Busqueda(busqueda, cant);
                if (id != -1)
                {
                    ViewBag.id = id;
                    detalle = c.UnEvento(id);
                }
                ViewBag.Detalle = detalle;
                c.Close();
            }
            catch (Exception e)
            {
            }
            ViewBag.Busqueda = busqueda;
            return View(datos);
        }
        /**
         * Muestra el XML devuelto por el servicio
         */ 
        public ActionResult WS()
        {
            WCF.EventosWCFClient c = new WCF.EventosWCFClient();
            XElement datos = c.Listado(10, 0);
            c.Close();
            return this.Content(datos.ToString(), "text/xml");
        }

        public ActionResult ServicioAJAX()
        {
            return View();
        }

        public ActionResult Widget()
        {
            return View();
        }
    }
}
